package com.example.lx5_22.fg

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.base.mvvm.BaseFragment
import com.example.lx5_22.R
import com.example.lx5_22.adapter.MessageAdapter
import com.example.lx5_22.databinding.FragmentMessageBinding
import com.example.lx5_22.message.MessageViewModel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch


class MessageFragment : BaseFragment<FragmentMessageBinding,MessageViewModel>() {

    val messageAdapter by lazy { MessageAdapter() }
    override fun initView() {
        binding.rvMessage.apply {
            adapter = messageAdapter
            layoutManager = LinearLayoutManager(requireContext())
        }
        lifecycleScope.launch {
            viewModel.getMessage().collect{
                messageAdapter.submitData(it)
            }
        }
    }

    override fun initData() {

    }

}